//
//  ViewController.swift
//  UITest
//
//  Created by 谢臣 on 2019/10/22.
//  Copyright © 2019 itcast. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    @IBOutlet var contentView: UIView!
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = UIColor.red
        // Do any additional setup after loading the view.
//        let testView = UIView.init(frame: CGRect())
//        testView.backgroundColor = UIColor.blue
//
//        view.addSubview(testView);
        
        print(view.safeAreaInsets)
        
        let view1 = MyView();
        view1.backgroundColor = UIColor.blue

        let view2 = MyView()
        view2.backgroundColor = UIColor.yellow
        
        let insets = UIApplication.shared.delegate?.window??.safeAreaInsets ?? UIEdgeInsets.zero
        
        
        view.addSubview(view1)
        view.addSubview(view2)
        let screenW = UIScreen.main.bounds.size.width
        let screenH = UIScreen.main.bounds.size.height
//        view1.frame = CGRect(x: 0, y: 0, width:screenW, height: 200)
//        view2.frame = CGRect( x: 0, y: screenH - 200, width:screenW, height: 200)
//
        view1.frame = CGRect(x: insets.left,y: insets.top,width:view.bounds.width - insets.left - insets.right,height: 200)
        view2.frame = CGRect(x: insets.left,y: screenH - insets.bottom - 200,width:view.bounds.width - insets.left - insets.right,height: 200)
       
    }


}

